package cc.idoone.spring_boot_hello.jms;

import org.springframework.jms.annotation.JmsListener;
import org.springframework.messaging.handler.annotation.SendTo;
import org.springframework.stereotype.Component;

/**
 * @auther hemj
 * @since 2017/9/28
 */
//@Component
public class Consumer {

	//@JmsListener(destination = "mytest.queue")
	public void exceptionQueue(String message) {
		System.out.println("Consumer0 收到的报文为: " + message);
		// throw new IllegalArgumentException("==== 测试异常情形 ====");
	}

	//@JmsListener(destination = "mytest.queue")
	public void receiveQueue(String message) {
		System.out.println("Consumer1 收到的报文为: " + message);
	}

	//@JmsListener(destination = "mytest.queue")
	@SendTo("out.queue") //该注解的意思是将return 返回的值，再发送到 "out.queue" 队列中
	public String receiveQueueAndBack(String message) {
		System.out.println("Consumer2 收到的报文为: " + message);
		return "return Consumer2 " + message;
	}

	//@JmsListener(destination = "mytest.queue")
	@SendTo("mytest.responseQueue")
	public String responseQueue(String message) {
		System.out.println("Consumer3 收到的报文为: " + message);
		return "return Consumer3 " + message;
	}

}
